<?php

/*

	Copyright © 2011 Mike Bennett <mike@kereru.com>

	This file is part of Tazu-Time.

    Tazu-Time is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    Tazu-Time is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Tazu-Time.  If not, see <http://www.gnu.org/licenses/>.
    
*/


/*
if ( basename(dirname(__FILE__)) == 'include' ) {

}
else {
	// Embedded resource list
	$h = res_open($argv[0]);
	$embedded_php = res_list($h,'PHP');
	//print_r($embedded_php);
}

function exe_resource($file) {  
	global $embedded_php;
	
	if ( basename(dirname(__FILE__)) == 'include' ) {
		return( $file );
	}
	else {

		// Check for an embedded version first, if there, load it otherwise try external phb 
		if ( in_array(strtoupper(md5($file)), $embedded_php ) ) {
			return defined('EMBEDED') ? 'res:///PHP/'.strtoupper(md5($file)):(getcwd() . "/$file");  
		}
		else {
			$phb = strtoupper(md5(basename($file,'.php'))).'.phb';
			return($phb);
		}

	}
}   
*/

function exe_resource($file) {  
	global $embedded_php;

	$path = dirname($file);
	$phb = basename($file,'.php').'.rdc';
	$phb2 = strtoupper(md5(basename($file,'.php'))).'.rdc';
	
//echo "[$file][$path\\$phb][$path\\$phb2]\n";

	if ( file_exists($path."\\".$phb2) ) return($path."\\".$phb2);
	elseif ( file_exists($path."\\".$phb) ) return($path."\\".$phb);
	return( $file );
}   


?>